#include <stdio.h>
#include <unistd.h>
#include <time.h>

#include "base_api.h"

void PrintReg(void)
{
    uint32_t ret = 0;
    for (int i=0; i<78; i++)
    {
        ret = ReadReg(REG1_ADDR + i * 4);
        printf("reg%d = 0x%08X \n", i + 1, ret);
    }
}

void ReadAll(void)
{
    uint32_t rowCount = 1152;
    uint32_t colCount = 128;
    uint32_t ret = 0;
    time_t t1=time(NULL);
    for (int i=0; i<rowCount; i++)
    {
        for (int j=0; j<colCount; j++)
        {
            ret = ReadOneCell_1(i, j);
        }
    }
    time_t t2=time(NULL);
    double tinterval = difftime(t2, t1);
    printf("the time interval is: %lf\n",tinterval);
}

int main(void)
{
    int EndNum = 0;
    int ret = OpenMMIO();
    printf("ret = %d \n", ret);

    DevInit();
    ret = SelectChip(0);
    printf("ret = %d \n", ret);
    ret = ReadOneCell_1(0, 0);
    printf("ret = %d \n", ret);
    // while(EndNum != 123)
    // {
    //     printf("Please input 123, if you want to stop. \n");
    //     scanf("%d", &EndNum);
    // }

    // ReadAll();
    // PowerOff();
    CloseMMIO();
    return 0;
}
